package com.lxq.blog.com.lxq.blog.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.access.hierarchicalroles.RoleHierarchy;
import org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class GlobalConfig implements WebMvcConfigurer {
    @Bean
    public RoleHierarchy roleHierarchy() {
        RoleHierarchyImpl impl = new RoleHierarchyImpl();
        impl.setHierarchy("final > 管理员 > VIP > 普通 > guest");
        return impl;
    }
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/repository/**")
                .addResourceLocations("file:/d:/blogRepository/");//结尾一定要加上“/”
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }
}
